
import java.io.IOException;
import java.io.RandomAccessFile;


//Class containing operations of datatype i1
public class i1 extends datatype implements read,write{

	public void write(String data, int length) throws IOException
	{
		//System.out.println("i1 write called");
		RandomAccessFile fi= new RandomAccessFile(heap.f,"rw");
		fi.seek(heap.f.length());
		byte b=Byte.parseByte(data);
		fi.write(b);
		fi.close();
	}
	public String read(int length) throws IOException
	{
		String str="";
		RandomAccessFile fip= new RandomAccessFile(heap.f, "rw");
		fip.seek(heap.readpointer);
		str=""+fip.readByte();
		heap.readpointer++;
		fip.close();
		return str;
		
	}
	public int compares(String value1,String value2) throws IOException
	{
		int result=0;
		byte record1=Byte.parseByte(value1);
		byte record2=Byte.parseByte(value2);
		result = record1>record2?1:record1<record2?2:0;
		return result;
	}
	public Object convert(String str)
	{
		byte b = Byte.parseByte(str);
		return b;
	}
	public byte[] returnPrimitive(String str)
	{
		byte b = Byte.parseByte(str);
		return new byte[]{b};
	}

	public Object getPrimitive(byte[] data)
	{
		return (data == null || data.length == 0) ? 0x0 : data[0];
	}
}
